package com.blog.cloud.dao;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.blog.cloud.comm.modal.dto.TagsDto;
import com.blog.cloud.comm.modal.pojo.GalleryTags;
import com.blog.cloud.comm.webutils.CommMethod;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;

public class GalleryTagsDao extends GalleryTags {

	
	public static GalleryTagsDao me = new GalleryTagsDao();
	public String tabName = CommMethod.getTbaleName("GalleryTags");
	
	
	
	public void insert(GalleryTags galleryTag ){
		galleryTag.save();
	}
	
	public void update(GalleryTags galleryTag ){
		galleryTag.update();
	}
	
	
	
	
	public List<TagsDto> geetGalleryTags(){
		List<TagsDto> resMap = null;
		String sql = "SELECT  tag_no, tag_names , COUNT(tag_names) as count FROM lexy_gallery_tags GROUP BY tag_names";
		List<Record> find = Db.find(sql);
		if(find!=null && find.size()>0){
			resMap = new ArrayList<TagsDto>();
			for (int i = 0; i < find.size(); i++) {
				TagsDto dto = new TagsDto();
				Record record = find.get(i);
				dto.setTagNo(record.getStr("tag_no"));
				dto.setTagName(record.getStr("tag_names"));
				dto.setCount(record.getStr("count"));
				resMap.add(dto);
			}
		}
		return resMap;
	}
	
}
